package com.dzx.permissionmanagersystem.common;

import com.dzx.permissionmanagersystem.entity.SysUser;

import javax.servlet.http.HttpServletRequest;

/**
 * @author DuanZhaoXu
 * @ClassName:
 * @Description:
 * @date 2018年11月30日 09:26:31
 */
public class RequestHolder {

     private  static   final ThreadLocal<SysUser>  userHolder = new ThreadLocal<SysUser>();

     private static final  ThreadLocal<HttpServletRequest> requestHolder = new ThreadLocal<HttpServletRequest>();


     public  static   void  add(SysUser sysUser){
          userHolder.set(sysUser);
     }


    public  static   void  add(HttpServletRequest request){
        requestHolder.set(request);
    }

    public static  SysUser getSysUser(){
          return  userHolder.get();
    }

    public static  HttpServletRequest getRequest(){
        return  requestHolder.get();
    }


    public   static  void  removeUser(){
         userHolder.remove();
    }

    public   static  void  removeRequest(){
        requestHolder.remove();
    }



















}

